/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.expression.function.math;

import org.amuthu.DataStore;
import org.amuthu.expression.Expression;
import org.amuthu.expression.exception.InvalidArgumentException;
import org.amuthu.expression.function.FunctionEvaluator;
import org.amuthu.parser.ExpressionVisitor;

/**
 *
 * @author prabhu
 */
public class PercentageFunction implements FunctionEvaluator
{
   public PercentageFunction()
   {
   }

   public double computeIndicator(DataStore dataStore, Expression[] arguments, ExpressionVisitor visitor) throws InvalidArgumentException
   {
      if (arguments.length < 2)
      {
         throw new InvalidArgumentException("Percentage function zero args");
      }

      double value = visitor.evaluate(arguments[0]);
      double percent = visitor.evaluate(arguments[1]);

      return value * percent / 100;
   }

   public int computeDayDependency(DataStore dataStore, Expression[] arguments, ExpressionVisitor visitor) throws InvalidArgumentException
   {
      return 0;
   }

}
